package unix

import "encoding/json"

type UnixResponse struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
	Data string `json:"data"`
}

func (res UnixResponse) Bytes() []byte {
	marshal, err := json.Marshal(res)
	if err != nil {
		return nil
	}

	return marshal
}

func Error(msg string) UnixResponse {
	u := UnixResponse{
		Code: 1,
		Msg:  msg,
		Data: "",
	}

	return u
}

func Ok(data string) UnixResponse {
	u := UnixResponse{
		Code: 0,
		Msg:  "ok",
		Data: data,
	}

	return u
}
